import { createWebHistory, createRouter } from 'vue-router'

import Login from '../view/Login/Login.vue'
import client from '../view/Client/Client.vue'
import HomePage from '../view/Client/HomePage.vue'
import Admin from '../view/Admin/Admin.vue'
import Dashboard from '../view/Admin/Dashboard.vue'

const routes = [
  {
    path: '/',
    component: Login
  },
  {
    path: '/client',
    component: client,
    children: [
      {
        path: 'HomePage',
        component: HomePage
      }
    ]
  },
  {
    path: '/admin',
    component: Admin,
    children: [
      {
        path: '',
        component: Dashboard
      }
    ]
  }
]

const router = createRouter({
  // 使用createWebHistory替代createMemoryHistory
  history: createWebHistory(),
  routes,
})

// 简单的路由守卫，只记录日志
router.beforeEach((to, from, next) => {
  console.log('导航到:', to.path)
  next()
})

export default router